<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Loading</title>
</head>
<body style="background: black; color: white; margin: 60px;">
       <div id="msg"> Check Box Setting on Cloud ... </div>
</body>
</html>
<script type="text/javascript" src="sdeviceinfo.js"></script>

<script type="text/javascript">

var activator = null;

function next() {
		location.replace( "init4.html" );
}

setTimeout( function() {
	var r = confirm( "No data , retry it? " );
	if ( ! r ) {
		return next();
	} else {
		location.reload();
	}
}, 1000 * 30 );

function goLocal() {
  var intent = wae.create("Intent");
  intent.startActivity("", "com.vatata.wae.localapp.LocalAppActivity");
  
  var app = wae.create("Application");
  app.finishActivity();
}

var timeoutFunc = setTimeout( function() {
		var r = confirm( "The box can not get response from server!\n"
						+ "Click CANCEL to skip network configration, and go to next step!\n"
						+ "Click OK to setup the network now!\n\n"
						+ "" );
		if ( !! r ) {
			goLocal();
			return;
		}else {
			next();
			return;
		}
	}, 1000* 30 );


function uni_onready(){
        var uiSettings = wae.create("UI.UISettings");
        uiSettings.set1080P();

 
	var sinfo = new SimpleDeviceInfo();
   var dinfo = sinfo.getinfo();

	clearTimeout( timeoutFunc );
	
  if ( ! dinfo ) {
		return next();
  }
  if ( ! dinfo  || ! dinfo.bo_id ) {
		return next();
  }

	var r = confirm( "Found BOX Setting in Cloud Services, use it? \n\nClick OK to use Cloud Settings, Or CACCEL to reinitialize it!" );
	if ( ! r ) {
		return next();
	}
 

  var server_url = dinfo.bo_url.replace( "index.php", "");
  var dobj = wae.create("DATA.Parameters");
  dobj.addContentProviderPersistenceWithAutoCommit("mainhosturl", server_url );

  var app = wae.create("Application");
  app.restartApplication();

}

window.onWAEReady = uni_onready;
</script>

